<?php
/**
 * Created by leiying
 * Date: 2017/11/21
 * Time: 11:46
 */

/**分页获取积分收支明细
 * @param $uid
 * @param $page
 * @param $page_size
 * @return array
 * @author leiying
 */
function get_integral_detail($uid,$page,$page_size){

    $count=$GLOBALS['db']->getOne('SELECT count(*) FROM '. $GLOBALS['db']->table("user_account").'WHERE `user_id`='.$uid.' AND change_action IN(\'sign_in\',\'cumulative\',\'price_ded\',\'poundage_ded\')');

    $page_count = ($count > 0) ? intval(ceil($count / $page_size)) : 1;

    $sql = 'SELECT change_desc,change_time,change_type,user_integral FROM '. $GLOBALS['db']->table("user_account").'WHERE `user_id`='.$uid.' AND change_action IN(\'sign_in\',\'cumulative\',\'price_ded\',\'poundage_ded\')  ORDER BY `change_time` DESC';

    $info = $GLOBALS['db']->selectLimit($sql, $page_size, ($page-1) * $page_size);

    $list = array();
    $arr = array();

    while ($row=$GLOBALS['db']->fetchRow($info)) {
        $arr['change_desc']= $row['change_desc'];
        $arr['change_time']= date("Y-m-d H:i:s",$row['change_time']);
        $arr['change_type']= $row['change_type'];
        $arr['user_integral']= $row['user_integral'];
        $list[] = $arr;
    }


    $pager = array(
        "total"  => $count,
        "count"  => count($list),
        "more"   => $page < $page_count ? 1 : 0
    );

    $res = array('list' =>$list, 'pager' => $pager);

    return $res;
}









